homeController.$inject = ['$scope', 'homeService', '$location'];

function homeController($scope, homeService, $location){
    var hc = this;
    $scope.passMerchantsInfo = {};
    
    homeService.getAllPassMerchantsFromA((err, result) => {
        //console.log(result.username);
        $scope.passMerchantsInfo = result;
    });

    hc.enterMerchantStore = function(merchantId){
        console.log("enterMerchantStore id....."+merchantId);
        sessionStorage.setItem("merchantId", merchantId);
        $location.path("/client/foods/merchantId/");
    }

    hc.getMerchantsByFoodType = function(type){
        console.log("type__"+type);
        homeService.getMerchantsByFoodType(type, (err, result) => {
            $scope.passMerchantsInfo = result;
        })
    }

    hc.getAllMerchants = function(){
        homeService.getAllPassMerchantsFromA((err, result) => {
            $scope.passMerchantsInfo = result;
        })
    }

    hc.loginOut=function(){
        console.log("ready to remove session");
        sessionStorage.removeItem("customer");
        console.log("have remove session");
        // console.log("111"+JSON.parse(sessionStorage.getItem("customer")));
        $location.path("/");
    }

}



module.exports = homeController;